<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    

<!DOCTYPE>
<html>
<!--后台管理中的目标库管理-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="../../bootstrap-table/bootstrap.min.css" />
<link rel="stylesheet" href="../../bootstrap-table/bootstrap-table.css">
<link rel="stylesheet" href="../../css/top.css" />
<link rel="stylesheet" href="../../css/home.css" />
<link rel="stylesheet" href="../../css/other.css" />
<link rel="stylesheet" href="../../css/window.css" />
<link rel="stylesheet" href="../../font-awesome-4.6.3/css/font-awesome.min.css" />
<script src="../../js/jquery.min.js"></script>
<script src="../../js/top_control.js"></script>
<script src="../../js/target_control.js"></script>
<script src="../../js/window.js"></script>
<script src="../../bootstrap-table/bootstrap-table.js"></script>
<script src="../../bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<title>智行校园-精准化服务平台</title>
</head>
<body class="background">
<input  type="hidden" value="目标库管理" id="the_goal"/>

<div class="container ">
	<div class="targets_left col-2" style="margin-left:0;width:10em"></div>
	<div class="targets_right " style="width:calc(100% - 13.7em);margin-top:0em">
          <h3 style="width:100%">目标库管理</h3>
		      <label>搜索关键词：</label>
		      <input placeholder="请输入目标名称"  /><button class="search_button">搜索</button>
		      <a class="add_target" href="add_target.jsp" style="margin-top:2em">+新增目标</a>
		    <div class="points_buttons"></div>
			<table id="the_table" ></table>
	</div>
</div>
<div id="table_dialog" style="display:none;" class="table_dialog"></div>
<script src="../../js/leftcol_control.js"></script>
<script>
var user_id=$('input#user_id').attr('value');
$(function() {
	$.ajax({
		url:'../../jsp/target/target_type.json',
		type:'post'
	}).done(function(data){
		for(var i=0;i<data.length;i++){
	     if(data[i].sign=='1'){
		   if(i==0)
			 $('div.points_buttons').append('<button class="selected" value="'+data[i].type+'">'+data[i].name+'</button>');
	       else
			 $('div.points_buttons').append('<button value="'+data[i].type+'">'+data[i].name+'</button>');
	     }
		}
		 paint_table("the_table","../../jsp/target/target_database.json?param2="+$('div.points_buttons button.selected').attr('value')+" &param1= "+user_id,colums,8, true,'',onClickRow);
		 $('div.points_buttons button').click(function() {
			    var the_type=$(this).attr('value');
				$(this).addClass('selected').siblings().removeClass('selected');
				$('#the_table').bootstrapTable('refresh',{
					url:'../../jsp/target/target_database.json? param2='+the_type+' &param1='+user_id
				});
			});
	});
	var colums = [[ "t_name", "t_source","t_describe", "t_buider","t_follow_num"],
	              [ "名称", "所属分类", "描述", "提供人" ,"关注人数"] ];
	
   
	
	$('div.targets_right button.search_button').click(function(){
		$('#the_table').bootstrapTable('refresh',{
			url:"../../jsp/target/target_database.json? param2= "+$('div.points_buttons button.selected').attr('value')+" & param3="+$(this).prev().val()+" & param1="+user_id
		});
	});
});
function paint_table(id, data,colums, number, pagination,height,onClickRow) {
	var colum = [];
	for (var i = 0; i < colums[0].length; i++){
    		   colum[i]={field:colums[0][i],title:colums[1][i],valign:"middle",align:"center"};
	}
	$('#' + id).bootstrapTable({
		url : data,
		columns : colum,
		height:height,
		sidePagination : 'server',
		pagination : pagination,
		onClickRow:onClickRow,
		pageSize : number,
		search : false,
		searchOnEnterKey : true,
		locale : 'zh-CN'
	});		
}

  function onClickRow(row, $element){
	  target_control(row.t_id,'table_dialog',$('div.header_tright img').attr('src'), user_id,$('div.header_tright a:eq(2)').text());
	}


</script>
</body>
</html>